#pragma once

#include "common.h"
#include <string>

enum RailroadCarType {
    FLAT_CAR = 0, // 平车
};

class RailroadCarProperty {
public:
    std::string name;     // 车厢型号
    RailroadCarType type; // 车厢类型
    fp_type length;        // 车长 m
    fp_type designSpeed;   // 构造速度 km/h
    fp_type deadWeight;    // 自重 t
    fp_type maxLoad;       // 最大载重 t

    RailroadCarProperty(const std::string &name, RailroadCarType type,
                        fp_type length, fp_type designSpeed, fp_type deadWeight,
                        fp_type maxLoad)
        : name(name), type(type), length(length), designSpeed(designSpeed),
          deadWeight(deadWeight), maxLoad(maxLoad) {};
};

class RailroadWagon {
public:
    explicit RailroadWagon(RailroadCarProperty *property);
    /**
     * 计算车厢的阻力，单位为kN。
     * @param v 车厢速度，单位km/h
     * @param w_i 当前区段的阻力系数，单位为kN
     * @return 阻力，单位为kN。
     */
    fp_type friction(fp_type v, fp_type w_i);
    // 获取长度
    inline fp_type getLength() { return this->property->length; };
    // 获取属性
    RailroadCarProperty *getProperty() { return property; };
    // 设置车厢的载重（单位：t）
    inline void setLoad(fp_type load) { this->load = load; };
    // 获取车厢的总重（单位：t）
    inline fp_type totalMass() { return this->load + this->property->deadWeight; };
    ~RailroadWagon();

private:
    int id;                        // 车厢id
    fp_type load;                   // 载重 t
    RailroadCarProperty *property; // 车厢属性
};

fp_type calculateRailroadCarFriction(RailroadCarProperty *car, fp_type load,
                                    fp_type v, fp_type w_i);
